package com.situ.student.controller;

import java.io.IOException;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.omg.PortableServer.ID_ASSIGNMENT_POLICY_ID;

import com.situ.student.service.IStudentService;
import com.situ.student.service.impl.StudentServiceImpl;

public class DeleteStudentServlet extends HttpServlet{
	private IStudentService studentService = new StudentServiceImpl();

	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		//1、得到浏览器传递过来的参数信息
		Integer id = Integer.parseInt(req.getParameter("id"));
		//2、调用service处理
		boolean result = studentService.deleteById(id);
		System.out.println(result ? "成功" : "失败");
		//3、重定向到列表界面
		//resp.sendRedirect("/Java1807Web/findStudent");
		
		//转发
		req.getRequestDispatcher("/findStudent").forward(req, resp);
		
	}
}
